<?php
/**
 * News.php
 * 
 * @category    Madoqua
 * @package     Module
 * @subpackage  Admin
 */


/** zend feed rss */
require_once 'Zend/Feed/Rss.php';

/** caching */
require_once 'Madoqua/Cache/News.php';

/**
 * News.php
 * 
 * news parser
 * 
 * @category    Madoqua
 * @package     Module
 * @subpackage  Admin
 */
class Admin_News
{
    /**
     * fetch the news (like a dog fetches a paper, only with a dikdik, not a dog)
     *
     * includes caching
     * 
     * @return Zend_Feed|bool
     */
    public static function fetch()
    {
        $url = trim(Madoqua_Application::getConfiguration()->madoqua->news_url);
        //url to madoqua's news section
        return Madoqua_Cache_News::get($url);
    }
    
    /**
     * build the news, without caching
     *
     * @return Zend_Feed|bool
     */
    public static function build($url)
    {
        try {
            $rss = new Zend_Feed_Rss($url);
            //parse rss, like a good dikdik
            return $rss;
        } catch (Zend_Feed_Exception $e) {
            //ahw :(
            return false;
        }        
        
    }
}